import java.util.*;

public class PassTwoDimensionalArray {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int[][] m = new int[3][4];
        System.out.println("Ievadi " + m.length + " rindas un "
                + m[0].length + " kolonnas: ");
        for (int i = 0; i < m.length; i++) {
            for (int j = 0; j < m[i].length; j++) {
                m[i][j] = scanner.nextInt();
            }
        }
        
        System.out.println("\nVisu elementu summa ir " + sum(m));
    }
    
    public static int sum(int[][] m) {
        int total = 0;
        for (int i = 0; i < m.length; i++) {
            for (int j = 0; j < m[i].length; j++) {
                total += m[i][j];
            }
        }
        
        return total;
    }
}